package com.dotstone.chipism.ui.security.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.dotstone.chipism.R;

/**
 *
 * 摄像头重置状态dialog
 */
public class CameraResetStatusDialog extends Dialog {

    private static CameraResetStatusDialog dialog;

    public CameraResetStatusDialog(@NonNull Context context) {
        super(context);
        setContentView(R.layout.dialog_camera_reset_status);
        Button btn_know = (Button) findViewById(R.id.btn_know);
        btn_know.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public CameraResetStatusDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        setContentView(R.layout.dialog_camera_reset_status);
        Button btn_know = (Button) findViewById(R.id.btn_know);
        btn_know.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public static void showDialog(final Activity activity){
        if (dialog == null){
            dialog = new CameraResetStatusDialog(activity);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setOnDismissListener(new OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    dialog = null;
                    activity.finish();
                }
            });
            dialog.show();
        }
    }

}
